import Vue from 'vue'
import Vuex from 'vuex'

// Vue.use(Vuex)

export default ({
  state: {

    editableTabsValue: 'Index',
    editableTabs: [{
      name: 'Index',
      title: '首页'
    }],

    hasRoute: false,
    menuList: [],
    permList: [],


  },
  mutations: {

    addTabs: (state, tab) => {
      let index = state.editableTabs.findIndex(item => item.name === tab.name)
      if (index === -1){
        state.editableTabs.push(tab)
      }
      state.editableTabsValue = tab.name
    },
    setMenuList: (state, menus) => {
      state.menuList = menus
    },

    setPermList: (state, perms) => {
      state.permList = perms
    },

    changeRouteStatus: (state, hasRoute) => {
      state.hasRoute = hasRoute
    },

    resetState: (state) => {
      state.menuList = []
      state.permList = []

      state.hasRoutes = false
      state.editableTabsValue = 'Index'
      state.editableTabs = [{
        name: 'Index',
        title: '首页'
      }]
    },
  },
  actions: {
  },
  modules: {
  }
})
